﻿using Entities;
using Microsoft.AspNetCore.Mvc;
using SqlSugar;
using WMS.DtoModels;

namespace Portal.Controllers
{
    public class NoticeController : Controller
    {
        private readonly SqlSugarClient _sqlSugarClient;

        public NoticeController(SqlSugarClient sqlSugarClient)
        {
            _sqlSugarClient = sqlSugarClient;
        }

        /// <summary>
        /// 加载所有系统公告
        /// </summary>
        /// <returns></returns>
        public IActionResult LoadAllNotice(NoticeInfoReqDto noticeInfoReqDto)
        {
            var totalCount = 0;
            var querySqlQueryable = this._sqlSugarClient.Queryable<sys_notice>();

             var queryResult = querySqlQueryable.ToPageList(noticeInfoReqDto.Page, noticeInfoReqDto.Limit, ref totalCount);

             var result = new
             {
                 Code = 0,
                 Msg = "查询成功",
                 Count = totalCount,

                 Data = queryResult
             };

             return Json(result);
        }
    }
}